﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;

namespace SBRepository
{
    /// <summary>
    /// Generic read-only entity repository.
    /// </summary>
    /// <typeparam name="TEntity">The type of the entity.</typeparam>
    public interface IReadOnlyRepository<TEntity> : IDisposable where TEntity : class, new()
    {
        /// <summary>
        /// Gets the entity by specified ID.
        /// </summary>
        /// <param name="id">The value of ID.</param>
        /// <returns>Entity.</returns>
        TEntity GetById(object id);

        /// <summary>
        /// Gets all entities from the specified data source.
        /// </summary>
        /// <returns>Entities.</returns>
        IEnumerable<TEntity> GetAll();

        /// <summary>
        /// Gets all entities from the specified data source.
        /// </summary>
        /// <param name="predicate">The predicate to filter result.</param>
        /// <returns>Entities.</returns>
        IEnumerable<TEntity> GetAll(Expression<Func<TEntity, bool>> predicate);

        /// <summary>
        /// Gets the query that returns all entities from the specified data store.
        /// </summary>
        /// <returns>The query.</returns>
        IQueryable<TEntity> QueryAll();

        /// <summary>
        /// Specifies what additional entities include while loading main entity.
        /// </summary>
        /// <param name="includes">Additional entities to include.</param>
        void Include(params Expression<Func<TEntity, object>>[] includes);
    }
}
